const Service = require('egg').Service;
const { toBase64 } = require('../util')

class InfoService extends Service {
    async getInfo() {
        const { ctx, app } = this;
        let userInfo = {
            username: '',
            account: '',
            wechat: '',
            QQ: '',
            github: '',
            keywords: '',
            description: '',
            sendword: '',
            userId: ''
        }
        if (ctx.session.userInfo) {
           userInfo = Object.assign({}, ctx.session.userInfo)
           delete userInfo['sessionId']
        }
        return {
            success: true,
            userInfo: toBase64(JSON.stringify(userInfo))
        }
    }
}

module.exports = InfoService;